#ifndef COMMON_DEFINE_H
#define COMMON_DEFINE_H
#include "opencv2\opencv.hpp"
#include <string>
#include <vector>
#include <chrono>

using person_info_type = std::pair<std::string, float>;

struct InfoRect {
	int flag = 0;
	cv::Rect rect;
	cv::Mat I_crop;
	int gender[3] = { -1,-1,-1 };
	std::string gender_s;
	std::vector<float> ages = std::vector<float>(7,0.0f);
	int age_flag = 3;

	int face_detect_times = 0;
	int rectstatus;
	std::string time_s;
	std::vector<person_info_type> person_info;
	std::string person_id = "Unknow";
	bool is_vip = false;
	int non_vip_order = 0;
	int vip_order = 0;
	int out_order = 0;
	int draw_name_cnt = 50;
	bool has_in = false;
	bool has_out = false;
	////only use when save face
	//std::vector<cv::Mat> id_faces;
	//std::vector<cv::Mat> id_bodies;
	//std::vector<cv::Mat> gender_faces;
	//std::vector<cv::Mat> gender_bodies;

	void info_update(const InfoRect& info_new, bool all=false)
	{
		face_detect_times = info_new.face_detect_times;
		rect = info_new.rect;
		rectstatus = info_new.rectstatus;
		//memcpy(info.gender, info_new.gender, 3 * 4);
		gender[0] = info_new.gender[0];
		gender[1] = info_new.gender[1];
		gender[2] = info_new.gender[2];
		flag = info_new.flag;
		I_crop = info_new.I_crop;
		gender_s = info_new.gender_s;
		time_s = info_new.time_s;
		person_info = info_new.person_info;
		person_id = info_new.person_id;
		is_vip = info_new.is_vip;
		ages = info_new.ages;
		age_flag = info_new.age_flag;

		if (all)
		{
			non_vip_order = info_new.non_vip_order;
			vip_order = info_new.vip_order;
			out_order = info_new.out_order;
			draw_name_cnt = info_new.draw_name_cnt;
			has_in = info_new.has_in;
			has_out = info_new.has_out;
		}
	}
};

struct TotalInfo
{
	int num_in = 0;
	int num_out = 0;
	int male_in = 0;
	int female_in = 0;
	int vip_in = 0;
	int non_vip_in = 0;
	std::vector<InfoRect> person_in;
	std::vector<InfoRect> person_out;
	int limit_size = 5;
	int time_index = 0;
	std::vector<int> num_in_per10min = std::vector<int>(144,0);
	std::vector<int> age_sum = std::vector<int>(7,0);
};

struct Door_Params
{
	int door_left_x;
	int door_left_y;
	int door_right_x;
	int door_right_y;
	std::vector<int> to_vector()const
	{
		return{ door_left_x,door_left_y,door_right_x,door_right_y };
	}
};

struct Track_Info
{
	std::vector<std::pair<cv::Point, bool>> trace_points;
	cv::Rect rect;
	int track_id;
	InfoRect info;
	Track_Info(std::vector<std::pair<cv::Point,bool>>&& points, const cv::Rect& rect_, const InfoRect& info_, int track_id_):
		trace_points(std::move(points)),rect(rect_),track_id(track_id_),info(info_){}
};

struct Video_Params
{
	std::string video_mode = "online";//"online" or "local"
	int m_fps = 25;
	int m_startFrame = 0; //only for "local"
	int m_endFrame = 0; //only for "local"
	std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds> start_time;
	std::string video_source;
	int rotate = -1; //-1 do not roate  ROTATE_90_CLOCKWISE = 0, ROTATE_180 = 1, ROTATE_90_COUNTERCLOCKWISE = 2
};

#endif // !COMMON_DEFINE_H
